Skip to content

[ARM] Deployment stacks What-If support#32854

Open
kalbert312 wants to merge 48 commits intoAzure:devfrom
kalbert312:kylea/stacks-what-if
Open

[ARM] Deployment stacks What-If support#32854
kalbert312 wants to merge 48 commits intoAzure:devfrom
kalbert312:kylea/stacks-what-if

Conversation

@kalbert312
Copy link
Copy Markdown
Member

@kalbert312 kalbert312 commented Feb 25, 2026

Related command
az stack-whatif

Description
Adds stack-whatif commands to Az CLI. This is a new resource type in ARM that stores previews of operations on deployment stacks. This may become a subcommand, or a flag to existing stack commands in the future, depending on customer feedback. The reason this is not added as a subcommand now is there is a subcommand hierarchy conflict:
az stack what-if group conflicts with az stack group where what-if is an action vs group which is a scope.
az stack group what-if would operate on a what-if entity, not a stack, which conflicts with the hierarchy.
Happy to take other suggestions if az stack-whatif is not desired.

Testing Guide
See test_resource_stacks.py for live test examples. Note at the time of writing, these commands currently only work in Canary regions, but full prod availability is expected by the end of the month.

History Notes

[ARM] az stack-whatif group/sub/mg: Add deployment stacks what-if commands.


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Feb 25, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@yanzhudd yanzhudd removed their assignment Mar 30, 2026
@yonzhan yonzhan requested a review from yanzhudd April 7, 2026 00:14
@kalbert312 kalbert312 marked this pull request as ready for review April 7, 2026 15:42
Copilot AI review requested due to automatic review settings April 7, 2026 15:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new az stack-whatif command surface to the resource module to create/show/list/delete deployment stack What-If results across RG/subscription/management-group scopes, including a dedicated pretty-printer for stack What-If output and accompanying tests/recordings.

Changes:

  • Register new stack-whatif {group|sub|mg} {create|show|list|delete} command groups and arguments, plus help text and linter exclusions.
  • Add a stack What-If pretty formatter (DeploymentStacksWhatIfResultFormatter) and extend shared color/formatting utilities.
  • Add live-scenario tests + recordings, and a unit test + sample JSON for formatter output.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/azure-cli/service_name.json Map az stack-whatif to the ARM “Resource Manager” service link.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_stack_formatters.py New unit test for stack What-If pretty formatting.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/test_resource_stacks.py New scenario tests for stack-whatif create/show/list/delete.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_deployment_stack_what_if_at_subscription.yaml Playback recording for subscription-scope stack-whatif scenario.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_deployment_stack_what_if_at_resource_group.yaml Playback recording for RG-scope stack-whatif scenario.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/recordings/test_deployment_stack_what_if_at_management_group.yaml Playback recording for MG-scope stack-whatif scenario.
src/azure-cli/azure/cli/command_modules/resource/tests/latest/data/stacks-what-if/what-if-1.json Sample stack What-If payload used by formatter unit tests.
src/azure-cli/azure/cli/command_modules/resource/linter_exclusions.yml Add linter exclusions for stack-whatif command groups/params.
src/azure-cli/azure/cli/command_modules/resource/custom.py Implement stack-whatif create/show pretty-print behavior and wiring to the formatter.
src/azure-cli/azure/cli/command_modules/resource/commands.py Register new stack-whatif command groups and operations.
src/azure-cli/azure/cli/command_modules/resource/_utils.py Add str_lower_eq helper used by stack-whatif formatter comparisons.
src/azure-cli/azure/cli/command_modules/resource/_stacks_formatters.py New pretty-printer for stack What-If results (stack-level + managed resource changes + diagnostics).
src/azure-cli/azure/cli/command_modules/resource/_params.py Add --no-color, introduce --stack-id for stack-whatif, and share argument wiring across stack/stack-whatif.
src/azure-cli/azure/cli/command_modules/resource/_help.py Add help entries + examples for az stack-whatif across scopes.
src/azure-cli/azure/cli/command_modules/resource/_formatters.py Adjust deployment What-If formatter behavior around “Unknown” scopes / missing relative IDs.
src/azure-cli/azure/cli/command_modules/resource/_color.py Extend color utilities (CYAN) and add indentation/insert helpers used by the new formatter.
src/azure-cli-core/azure/cli/core/helpIndex.latest.json Add top-level help index entry for stack-whatif.
src/azure-cli-core/azure/cli/core/commandIndex.latest.json Add stack-whatif to command index; also modifies network module mapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"network": [
"azure.cli.command_modules.network",
"azure.cli.command_modules.privatedns"
"azure.cli.command_modules.network"
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commandIndex.latest.json drops azure.cli.command_modules.privatedns from the network command group. Since azure/cli/command_modules/privatedns/ still exists, this likely breaks az network private-dns ... command loading under the optimized loader. Please regenerate the command index or re-add the privatedns module to the network entry.

Suggested change
"azure.cli.command_modules.network"
"azure.cli.command_modules.network",
"azure.cli.command_modules.privatedns"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this happened. I ran the script to update this.

kalbert312 and others added 2 commits April 7, 2026 12:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants